package alkaid.eis.sys.entity;

import java.util.Comparator;

/**
 * 地区排序
 *  
 * @author Lucky Yang
 * @since 0.0.1
 */
public class AreaComparator {
    public final static CodeComparator CODE = new CodeComparator();
    public final static PathCodeComparator PATHCODE = new PathCodeComparator();
    
    public static class CodeComparator implements Comparator<Area> {
        @Override
        public int compare(Area o1, Area o2) {
            String order1 = o1.getCode() == null ? "" : o1.getCode();
            String order2 = o2.getCode() == null ? "" : o2.getCode();
            return order1.compareTo(order2);
        }
    }

    public static class PathCodeComparator implements Comparator<Area> {
        @Override
        public int compare(Area o1, Area o2) {
            String order1 = o1.getPathCode() == null ? "" : o1.getPathCode();
            String order2 = o2.getPathCode() == null ? "" : o2.getPathCode();

            return order1.compareTo(order2);
        }
    }
}
